<?php 
include("admin_check.php");
include_once("../function.php");
include_once("../class/bonus_class.php");
include_once("../class/system_class.php");
include_once("../class/ulevel_class.php");
include_once("action.php");
session_start();
header("Content-Type: text/html;charset=utf-8");
date_default_timezone_set('PRC');
checkqx(2,6);
if ($_POST['button2']){
        $ymd=date('y-m-d');
        $date=strtotime($ymd);
        $admin=getMemberbyID(1);
        if($admin['qiandao']<$date) {
            $mey = $_POST['mey'];

            $sql = "SELECT sum(lsk) as slsk FROM `member` WHERE ispay>0 and ulevel=5";
            $sumlsk=getOne($sql);


            $sql2 = "SELECT id FROM `member` WHERE ispay>0 and ulevel=5";
            $re = mysql_query($sql2);
            $_bonus_cl = new bonus_class();
            while ($rs = mysql_fetch_assoc($re)) {
                $_bonus_cl->bonus1($rs['id'], $mey, $sumlsk);
                $_bonus_cl->b0bonus();
            }
            echo "<script language=javascript>alert('全球分红发放完成.');window.location.href='admin_bonuslaiyuan.php'</script>";
        }else{
            echo "<script language=javascript>alert('今日已发放.');window.location.href='?'</script>";
        }
        edit_sql("update member set qiandao where id=1");
}
if($_POST['button3']){
    $mey = $_POST['mey'];
    if($mey>0){
        edit_sql("update member set zb4=".$mey." where id=1");
        action::record("修改静态发放奖金",1, 1,(int)$mey);
    }else{
        echo "<script language=javascript>alert('请输入正确的金额.');window.location.href='?'</script>";
    }

}
$_system=new system_class();
$_ulevel=new ulevel_class();
$system=$_system->system_right();
$_iul=$_ulevel->getulevelbyulevel(1);
$dateymd=date("Y-m-d");
$date=strtotime($dateymd);
$zuotian=date("Y-m-d",strtotime("-1 day",$date));

$sql1="select zb4 from member where id=1";
$user1=getOne($sql1);
$sql="select * from systemyeji where ydate like '%{$zuotian}%'";
$sysyeji=getOne($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改静态奖业绩</title>
<link href="css/table.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="table1">
    <tr>
      <td align="center">当前金额为: <?php if($user1['zb4']>0){ echo $user1['zb4'];}else{ echo $sysyeji['xzyj'];}?></td>
  </tr>
    <tr>
      <td align="center">发放金额<input name="mey" type="text" id="mey" value=" "/></td>
  </tr>
  <tr >
    <td align="center">

      <input name="button3" type="submit" class="btn2" id="button3" value="静态奖修改" onClick="{if(confirm('您确定要修改奖金吗?')){this.document.selform.submit();return true;}return false;}"/>
   </td>
  </tr>
</table>
</form>
</body>
</html>